package com.jimmyhsu.ecnudaowei.common.views;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.jimmyhsu.ecnudaowei.login.LoginActivity;

/**
 * Created by jimmyhsu on 2017/4/25.
 */

public class BulletinItemDecoration extends RecyclerView.ItemDecoration {

    private int mDividerHeight;

    public BulletinItemDecoration(Context context, int dividerHeightInDp) {
        mDividerHeight = LoginActivity.dp2px(dividerHeightInDp, context);
    }


    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        if (parent.getChildAdapterPosition(view) == 0 ||
                parent.getChildAdapterPosition(view) == state.getItemCount() - 2) { // 有footer
            outRect.set(0, 0, 0, 0);
        } else {
            outRect.set(0, 0, 0, (int) Math.ceil(mDividerHeight));
        }
    }
}
